package ten;

public class 十四内部类 {
    //静态内部类
    static class Test01 implements Runnable {
        @Override
        public void run() {
            for (int i = 0; i < 5; i++) {
                System.out.println("听歌");
            }
        }
    }

    public static void main(String[] args) {
        //局部内部类
        class Test02 implements Runnable {
            @Override
            public void run() {
                for (int i = 0; i < 5; i++) {
                    System.out.println("吃饭");
                }
            }
        }
        new Thread(new Test01()).start();
        new Thread(new Test02()).start();

        //匿名内部类
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 5; i++) {
                    System.out.println("看电视");
                }
            }
        }).start();

        //lambda匿名内部类
        new Thread(()-> {
            for (int i = 0; i < 5; i++) {
                System.out.println("剪头发");
            }
        }).start();

    }
}
